home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 6.1 KB | 208 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPictur.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPICTUR_H
- #define FWPICTUR_H
-
- #ifndef FWGROBJ_H
- #include "FWGrObj.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWRESOUR_H
- #include "FWResour.h"
- #endif
-
- #ifndef FWPRIEXC_H
- #include "FWPriExc.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Error codes
- //========================================================================================
-
- const FW_PlatformError FW_xInvalidPictureData = -30022;
-
- //========================================================================================
- // Forward Class Declarations
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPictureRep;
- class FW_CLASS_ATTR FW_CPictureContext;
- class FW_CLASS_ATTR FW_GraphicDevice;
-
- //========================================================================================
- // class FW_PPicture
- //========================================================================================
-
- class FW_CLASS_ATTR FW_PPicture : public FW_CGraphicCountedPtr
- {
- public:
- FW_DECLARE_CLASS
-
- public:
- FW_PPicture();
- virtual ~ FW_PPicture();
-
- FW_PPicture(FW_PlatformPict platformPict);
- FW_PPicture(FW_CResourceFile& resourceFile, FW_ResourceId resourceId);
-
- FW_PPicture(const FW_PPicture& other);
- FW_PPicture(FW_CPictureRep* rep);
-
- FW_PPicture& operator=(const FW_PPicture& other);
- FW_PPicture& operator=(FW_CPictureRep* other);
-
- FW_CPictureRep* operator->();
- const FW_CPictureRep* operator->() const;
- };
-
- //========================================================================================
- // class FW_CPictureRep
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPictureRep : public FW_CGraphicCountedPtrRep
- {
- friend class FW_CLASS_ATTR FW_PPicture;
-
- public:
- FW_DECLARE_CLASS
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- private:
- FW_CPictureRep();
- FW_CPictureRep(FW_CReadableStream& archive); // fOwnPicture = TRUE
- FW_CPictureRep(FW_CResourceFile& resourceFile, FW_ResourceId resId); // fOwnPicture = TRUE
-
- FW_CPictureRep(FW_PlatformPict platformPict); // fOwnPicture = FALSE
-
- virtual ~FW_CPictureRep();
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- virtual void Flatten(FW_CWritableStream& archive) const;
- virtual FW_Boolean IsEqual(const FW_CGraphicCountedPtrRep* other) const;
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- // ----- Copying -----
- FW_PPicture Copy() const;
-
- // ----- Get, Set, Adopt and Orphan
- FW_PlatformPict GetPlatformPict() const; // return fPlatformPict
- FW_Boolean IsPlatformPictOrphan() const;
- FW_PlatformPict OrphanPlatformPict(); // return fPlatformPict, and change ownership
-
- void SetPlatformPict(FW_PlatformPict newPict); // fOwnPicture = FALSE
- void AdoptPlatformPict(FW_PlatformPict newPict); // fOwnPicture = TRUE
-
- void LoadPictureFromResource(FW_CResourceFile& resourceFile,
- FW_ResourceId resourceId); // fOwnPicture = TRUE
-
- // ----- Getter/Setter -----
- void GetPictBounds(FW_CRect& bounds) const; // Size in pixels
- void GetPictBounds(FW_CGraphicContext& gc, FW_CRect& bounds) const; // Size in gc units
-
- // ----- Archiving -----
- static void* Read(FW_CReadableStream& archive);
-
- void WriteTo(const FW_CWritableStream& stream) const;
- void ReadFrom(const FW_CReadableStream& stream);
-
- #ifdef FW_BUILD_MAC
- void MacLock();
- void MacUnlock();
- #endif
-
- protected:
- void DisposePlatformPict();
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- FW_Boolean fOwnPicture;
- FW_PlatformPict fPlatformPict;
-
- #ifdef FW_BUILD_MAC
- unsigned short fMacLockCount;
- #endif
- };
-
- //========================================================================================
- // class FW_CPictureContext
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPictureContext : public FW_CGraphicContext
- {
- public:
- FW_CPictureContext(Environment* ev,
- FW_PPicture& picture,
- FW_CFixed xSize,
- FW_CFixed ySize);
- // Size is in 72dpi
- virtual ~FW_CPictureContext();
-
- private:
- FW_PPicture& fPicture; // A reference because will modify the ref-cnt pointer
- FW_CGraphicDevice* fGraphicDevice;
-
- #ifdef FW_BUILD_MAC
- PicHandle fMacPictHandle;
- #endif
- };
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_PPicture::operator->
- //----------------------------------------------------------------------------------------
- inline FW_CPictureRep* FW_PPicture::operator->()
- {
- return (FW_CPictureRep*) GetRep();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PPicture::operator->
- //----------------------------------------------------------------------------------------
- inline const FW_CPictureRep* FW_PPicture::operator->() const
- {
- return (const FW_CPictureRep*) GetRep();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPictureRep::IsPlatformPictOrphan
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CPictureRep::IsPlatformPictOrphan() const
- {
- return !fOwnPicture;
- }
-
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-